package com.rc.web.controller;

import com.rc.common.annotate.WithoutTenant;
import com.rc.pojo.vo.adoptionInfo.AdoptionInfoVO;
import com.rc.web.service.AdoptionInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/adoptionInfo")
@Api(tags = "认养信息")
@RequiredArgsConstructor
@Validated
public class AdoptionInfoController {
    private final AdoptionInfoService adoptionInfoService;

    @GetMapping
    public AdoptionInfoVO getOneById(Long orderId) {
        return adoptionInfoService.getByOrderId(orderId);
    }

    @GetMapping("/list")
    public List<AdoptionInfoVO> getList(){
        return adoptionInfoService.getList();
    }

    @PutMapping("/endAdoption")
    @ApiOperation("结束认养")
    @WithoutTenant
    public void endAdoption(Long orderId){
        adoptionInfoService.endAdoption(orderId);
    }
}
